﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace CRMWeb.Utilities
{
    public static class FormatHelper
    {
        public static string FormatPrice(decimal? price)
        {
            return FormatHelper.FormatPrice(price, false);
        }

        public static string FormatPrice(decimal? price, bool addCurrencySymbolFlag)
        {
            return (price != null ? (addCurrencySymbolFlag ? "$" : "") + ((decimal)price).ToString("###,##") : "");
        }

        public static string FormatNumber(decimal? num)
        {
            return (num != null ? ((decimal)num).ToString("#####") : "");
        }

        public static string FormatDateTime(DateTime? dateTime)
        {
            if (dateTime == null || dateTime == DateTime.MinValue)
                return "";
            else
                return ((DateTime) dateTime).ToString("dd MMM yyyy hh tt");
        }
        public static string FormatDateTimeLong(DateTime? dateTime)
        {
            if (dateTime == null || dateTime == DateTime.MinValue)
                return "";
            else
                return ((DateTime)dateTime).ToString("dd MMM yyyy hh:mm tt");
        }
        public static string FormatDate(DateTime? dateTime)
        {
            if (dateTime == null || dateTime == DateTime.MinValue)
                return "";
            else
                return ((DateTime)dateTime).ToString("dd MMM yyyy");
        }
        public static string FormatDate2(DateTime? dateTime)
        {
            if (dateTime == null || dateTime == DateTime.MinValue)
                return "";
            else
                return ((DateTime)dateTime).ToString("MMM yyyy");
        }
        public static string FormatDateLong(DateTime? dateTime)
        {
            if (dateTime == null || dateTime == DateTime.MinValue)
                return "";
            else
                return ((DateTime)dateTime).ToString("dddd, dd MMMM yyyy");
        }
        
        public static string FormatStringWithFirstLetterUpper(string s)
        {
            if(s.Length>0)
                return s.Substring(0, 1).ToUpper() + s.Substring(1, s.Length-1).ToLower();
            else
                return s;
        }
    }
}